﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WebUtils;

namespace OAuth.SignatureMethods
{
    public class Plaintext : SignatureMethod
    {
        private static Plaintext instance;
        private Plaintext() { }

        public static Plaintext Instance
        {
            get
            {
                if (instance == null)
                    instance = new Plaintext();
                return instance;
            }
        }

        public override string Name { get { return "PLAINTEXT"; } }

        public override string CreateSignature(
            IUnsignedWebRequest pRequest, 
            IOAuthSessionParameter pSessionParameter,
            IEnumerable<UnEncodedURLParameter> pOAuthParameters)
        {
            var signature = string.Format(
                "{0}&{1}",
                pSessionParameter.ConsumerSecret,
                pSessionParameter.TokenStorage.TokenSecret);
            return signature;
        }
    }
}
